<?php
// +----------------------------------------------------------------------
// | Tplay [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://tplay.pengyichen.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 听雨 < 389625819@qq.com >
// +----------------------------------------------------------------------


namespace app\admin\controller;

use \think\Db;
// use app\admin\model\News as NewsModel;//管理员模型
use app\admin\controller\Permissions;
class IndexMenu extends Permissions
{
    /**
     * 导航列表
     * @return [type] [description]
     */
    public function index()
    {
        $type=$this->request->Post('type');
        if($type !='') $where['type']= ['=',$type];
        $index_menu =Db::name('index_menu')->order("id","asc")->paginate(20,false,['query'=>request()->Post()]);
        // var_dump($index_menu);
        $this->assign('index_menu',$index_menu);
        // // var_dump($news);
        return $this->fetch();
    }

    /**
     * 添加新闻
     */
    public function add(){
        // return 1111;
        if(request()->IsAjax()){
            $post=Request()->param();
            // return $post;
            Db::name("index_menu")->where("id",$post['id'])->update(["state"=>$post['state']]);
            return 0;
        }else{
            return 1;
        }
    }
    
}
